﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Net;
using Enyim.Caching.Memcached;
using Heavysoft.Mince.Models;

namespace Heavysoft.Mince.Controllers
{
    public class MemcachedController : Controller
    {
        //
        // GET: /Memcached/

        public ActionResult Index()
        {
            Enyim.Caching.Configuration.MemcachedClientConfiguration config = new Enyim.Caching.Configuration.MemcachedClientConfiguration();
            config.Servers.Add(new System.Net.IPEndPoint(IPAddress.Parse("192.168.0.12"), 11211));
            config.Protocol = Enyim.Caching.Memcached.MemcachedProtocol.Text; //you must set a protocol
            Enyim.Caching.MemcachedClient client = new Enyim.Caching.MemcachedClient(config);

            client.Store(Enyim.Caching.Memcached.StoreMode.Add, "hello", "Привет, Memcached! " + DateTime.Now.ToLongTimeString());

            Photo photo0 = new Photo();
            photo0.Name = "бла=-блавапв-апы";
            bool res = client.Store(StoreMode.Set, "photo0", photo0);

            Photo photo1 = client.Get<Photo>("photo0");
            Object o = client.Get("photo0");

            ViewData["Message"] = client.Get("hello");

            return View();
        }

    }
}
